package com.example.demo.xcel;

import lombok.Data;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author FENGYU
 * @description
 * @date 2024-01-05 15:54
 */
@Data
public class Code {

    public static Set<String> codeSet = new HashSet<>();

    private static final ThreadPoolExecutor executor = new ThreadPoolExecutor(64, 64, 0L,
            TimeUnit.MINUTES, new LinkedBlockingQueue<>(32));



    public static void main(String[] args) {
        for (int i = 0; i <100 ; i++) {
            CountDownLatch countDownLatch = new CountDownLatch(34);
            for (int j = 0; j < 34; j++) {
                executor.execute(() -> {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
               //     System.out.println("执行中");
                    countDownLatch.countDown();
                });
            }
            try {
                System.out.println("等待执行完毕");
                countDownLatch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("执行完毕");
        }




    }

    public static void sssss() {
        StringBuffer sb = new StringBuffer();
        sb.append("select ur.user_release_id, ur.status, ur.period_num, ur.release_amount, ur.lock_date, ur.release_date, ur.trigger_Date, ur.release_type, ");
        sb.append("ur.xproject_contact_id, ur.user_id, ur.contact_id, ur.release_percent, ur.user_achievement_id, ur.payment_percent,ur.plus_value as ur_plus_value, ");
        sb.append(" xp.unlock_date as unlockDate, xp.has_unlocked as hasUnlocked, ");
        //sb.append("ur.xproject_contact_id, ur.user_id, ur.contact_id, ur.release_percent, ur.user_achievement_id, ur.payment_percent,xp.paid_amount as ur_plus_value, ");
        sb.append("ur.assign_position, ur.plus_percent, ur.rec_status, ur.product_id, ur.contact_Source_percent as contactSourcePercent, ");
        // 客户信息
        sb.append("contact.name as contactName, contact.code as contactCode, ");
        // 产品信息
        sb.append("pro.name as proName, pro.sub_type1, pro.sub_type2, ");

        // 用户信息
        sb.append("us.user_id, us.user_code, us.user_name, us.real_name,");
        // 合同信息
        sb.append("xp.xproject_contact_id, xp.xproject_code, xp.actual_Amount, xp.charge_person_id, xp.sure_release_status, xp.pay_status, xp.discount_sum, xp.paid_amount, ");
        // 班级信息
        sb.append("class.code class_code, class.class_status class_status,");
        sb.append("xp.CREATE_DATE AS xp_create_date, ");          //订单创建时间
        sb.append("xp.REGISTRATION_STATUS AS REGISTRATION_STATUS");          //注册状态

        // 提成分配信息
        sb.append(" from user_release ur ");
        sb.append("LEFT JOIN BCONTACT CONTACT ON UR.CONTACT_ID = CONTACT.CONTACT_ID ");
        sb.append("LEFT JOIN PRODUCT PRO ON UR.PRODUCT_ID = PRO.PRODUCT_ID ");
        sb.append("LEFT JOIN SYS_USER US ON UR.USER_ID = US.USER_ID ");
        sb.append("LEFT JOIN XPROJECT_CONTACT xp ON UR.XPROJECT_CONTACT_ID = xp.XPROJECT_CONTACT_ID ");
        sb.append("LEFT JOIN student student ON student.contact_id = contact.contact_id and student.xproject_contact_id = xp.XPROJECT_CONTACT_ID AND student.VALID_STATUS = 'A' ");   // 重复记录 bclass 一个客户入多个班，保留一个有效的班级
        sb.append("LEFT JOIN bclass class ON class.class_id = student.class_id ");
        sb.append(" left join sys_user su on su.user_id = xp.charge_person_id ");
        sb.append(" where 1=1 ");

        sb.append("and ( 1 <> 1 ");

        sb.append("and xp.xproject_code = 'R20231027402897' ");

        sb.append("and contact.code = 'C2023092789536' ");

        sb.append("and contact.name = 'wang peter' ");

        sb.append("and pro.name = '博商马来西亚总裁班（2023）' ");

        sb.append("and us.user_code = 'B07354' ");


        sb.append(") ");

        sb.append("AND ur.rec_date <= ? AND ur.rec_date >= ? ");

        System.out.println(sb);

    }


    public static void ffff() {

        StringBuffer sb = new StringBuffer();
        sb.append("select ur.user_release_id, ur.status, ur.period_num, ur.release_amount, ur.lock_date, ur.release_date, ur.trigger_Date, ur.release_type, ");
        sb.append("ur.xproject_contact_id, ur.user_id, ur.contact_id, ur.release_percent, ur.user_achievement_id, ur.payment_percent,ur.plus_value as ur_plus_value, ");
        sb.append("ur.assign_position, ur.plus_percent, ur.rec_status, ur.product_id, ur.contact_Source_percent as contactSourcePercent, ");
        // 客户信息
        sb.append("contact.name as contactName, contact.code as contactCode, ");
        // 产品信息
        sb.append("pro.name as proName, pro.sub_type1, pro.sub_type2, ");

        // 用户信息
        sb.append("us.user_id, us.user_code, us.user_name, us.real_name,");
        // 子订单信息
        sb.append("soi.id as subOrderId, soi.sub_order_no, soi.sub_order_payment_money, soi.sub_order_sale_money, soi.CREATE_DATE AS create_date, ");
        sb.append("soi.sure_release_status, soi.sub_order_status, oi.order_head_user, soi.registration_status as registrationStatus, ");
        sb.append("soi.sub_order_paid_money, soi.sub_order_discount_money, soi.unlock_date as unlockDate, soi.has_unlocked as hasUnlocked, ");
        // 订单完整状态
        sb.append("oi.payment_status, soi.sub_order_status, soi.after_sales_status ");

        // 提成分配信息
        sb.append(" from user_release ur ");
        sb.append("LEFT JOIN BCONTACT CONTACT ON UR.CONTACT_ID = CONTACT.CONTACT_ID ");
        sb.append("LEFT JOIN PRODUCT PRO ON UR.PRODUCT_ID = PRO.PRODUCT_ID ");
        sb.append("LEFT JOIN SYS_USER US ON UR.USER_ID = US.USER_ID ");
        sb.append("LEFT JOIN sub_order_info soi ON UR.XPROJECT_CONTACT_ID = soi.id ");
        sb.append("LEFT JOIN order_info oi ON oi.id = soi.order_id ");
        sb.append(" where 1=1 and soi.id is not null AND soi.rec_status = 'A' ");

        sb.append("and ( 1 <> 1 ");

        sb.append("and soi.sub_order_no = 'R20231027402897' ");

        sb.append("and contact.code = 'C2023092789536' ");

        sb.append("and contact.name = 'wang peter' ");

        sb.append("and pro.name = '博商马来西亚总裁班（2023）' ");
        sb.append("and us.user_code = 'B07354' ");

        sb.append(") ");

        sb.append("AND ur.rec_date <= ? AND ur.rec_date >= ? ");

        System.out.println(sb);
    }

}
